package com.situ.web.listener;

import javax.servlet.http.HttpSessionAttributeListener;
import javax.servlet.http.HttpSessionBindingEvent;
// 监听往HttpSession中setAttribute、removeAttribute操作
public class MyHttpSessionAttributeListener implements HttpSessionAttributeListener{

	// 监听第一次添加session.setAttribute("name", "zhangsan");
	@Override
	public void attributeAdded(HttpSessionBindingEvent se) {
		System.out.println("MyHttpSessionAttributeListener.attributeAdded()");
	}

	@Override
	public void attributeRemoved(HttpSessionBindingEvent se) {
		System.out.println("MyHttpSessionAttributeListener.attributeRemoved()");
	}

	// 后面覆盖name session.setAttribute("name", "lisi");
	@Override
	public void attributeReplaced(HttpSessionBindingEvent se) {
		System.out.println("MyHttpSessionAttributeListener.attributeReplaced()");
	}

}
